package com.lglbc.day18;

import com.alibaba.fastjson.JSON;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 乐哥聊编程
 * @Doc 关注公众号"乐哥聊编程"获取文档和源码
 * @Date 2023/4/22
 * @Description
 */
@RestController
public class IndexController {
    @RequestMapping("/admin")
    @PreAuthorize("hasAnyAuthority('admin:write')")
    public String admin(Authentication authentication){
        return JSON.toJSONString(authentication);
    }
    @RequestMapping("/superAdmin")
    @PreAuthorize("hasAnyAuthority('super:write')")
    public String superAdmin(Authentication authentication){
        return JSON.toJSONString(authentication);
    }
}
